import React from 'react';
import { inject, observer } from 'mobx-react';
import { Col, Row } from 'antd';
import { WeaLocaleProvider } from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;

@inject('documentDetailStore')
@observer
class DataListItem extends React.PureComponent {
	openFullWindowForXtable = () => {
		const { v } = this.props;
		let href = `/spa/document/index2file.jsp?id=${v.id}&imagefileId=${v.imagefileid}&versionId=${v.versionId}&router=1${v.otherparams && v.otherparams}${window.__moudleParams}#/main/document/fileView`;
		window.openFullWindowForXtable(href);
	}
	onOperatesClick2 = () => {
		const { onOperatesClick, v, index } = this.props;
		if (typeof onOperatesClick === 'function') onOperatesClick(v, index, '', '2');
	}
	onOperatesClick1 = () => {
		const { onOperatesClick, v, index } = this.props;
		if (typeof onOperatesClick === 'function') onOperatesClick(v, index, '', '1');
	}
  render() {
		const { v, index, documentDetailStore: { docAutoExtendInfo: { canDownload = false } } } = this.props;
		return (
			<Col ecId={`${this && this.props && this.props.ecId || ''}_Col@75y630@${v.imagefilename}`} xs={24} sm={24} md={12}>
					<Row ecId={`${this && this.props && this.props.ecId || ''}_Row@wx6t4z@${v.imagefilename}`} className="file-single">
						<Col ecId={`${this && this.props && this.props.ecId || ''}_Col@s9onc9@${v.imagefilename}_span16`} span={16} className="text-elli">
							<span className="single-img" dangerouslySetInnerHTML={{ __html: v && v.docfiletype }} />
							<span className="single-title" title={v.imagefilename}>
								{v && <span onClick={this.openFullWindowForXtable}
									style={{ cursor: 'pointer' }}
								>{v.imagefilename}</span>}
							</span>
							{
									v && v.version != '0' &&
									<span>
										(
										<span
											style={{
												color: '#30B5FF',
												display: 'inline-block',
												verticalAlign: 'middle',
												cursor: 'pointer',
											}}
											onClick={this.onOperatesClick2}
										>
											V{v.version}
										</span>
										)
									 </span>
								}
						</Col>
						<Col ecId={`${this && this.props && this.props.ecId || ''}_Col@3u6rqq@${v.imagefilename}_span8`} span={8}>
							<span className="single-size">{v && v.filesize}</span>
							{
								canDownload && <span className="single-download"
									onClick={this.onOperatesClick1}
								>{getLabel(31156, '下载')}</span>
							}
							{
								v && v.version != '0' && <span className="single-version" 
								 	onClick={this.onOperatesClick2}
								>{getLabel(16384, '打开版本')}</span>
							}
						</Col>
					</Row>
				</Col>);
	}
}

export default DataListItem;
